package com.nfit.web.usersettings;

import com.nfit.entity.UserSettings;
import com.nfit.entity.vo.ResponeVo;
import com.nfit.service.UserSettingsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import static com.nfit.entity.vo.ResponeVo.fail;
import static com.nfit.entity.vo.ResponeVo.success;

@RestController
public class UserSettingsController {
    @Autowired
    private UserSettingsService service;

    @RequestMapping("/usersettings/userSettingsInfo")
    public ResponeVo userSettings(String userId) {
        return success(service.selectUserSettings(userId));
    }

    @RequestMapping("/usersettings/saveUserSettings")
    public ResponeVo saveUserSettings(String userId, Boolean email, Boolean username, Boolean phone) {
        if (service.saveUserSettings(userId, email, username, phone) > 0) {
            return success();
        }
        return fail("保存失败");
    }
}
